home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
dalla rivista
/
host contacted
/
imengv3.41p2.lha
/
ImEngV3.41p2
/
Extra
/
ARexx
/
IndexMultiply.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-01-06
|
2KB
|
65 lines
/*
** $VER: IndexMultiply.rexx 1.03 (4/1 Stockholm/Sweden)
** Copyright © 1997 by Patrik M Nydensten
**
** Clones a single file with an index number.
** The new name will be the old basename with a new index number ranging
** upwards or downwards. Positvie clone number makes the new indexes range
** upwards while negative makes them range downwards.
**
** Usage: <number_of_clones> <indexed file>
*/
options results
parse arg number files
if pos('"',files) = 0 then parse var files file1 .
else parse var files '"'file1'"'
if ~datatype(number,'N') then errorx('Error: Bad clone number.')
fix = strip(get_ext(file1)) ; lix = fix + number
if ((~datatype(fix,'N'))|(~datatype(lix,'N'))) then errorx('Error: Bad index number in file name.')
fi = min(fix,lix) ; li = max(fix,lix)
if ~exists(file1) then errorx('Error: Could not locate file "'file1'"')
do i = fi to li
if i = fix then iterate
if i < 1 then do
say 'Error: Index goes below 1.'
iterate
end
old_file = file1
new_file = get_base(file1)'.'right(i,4,'0')
if ~exists(new_file) then do
address 'COMMAND' 'copy' '"'old_file'"' '"'new_file'"'
end
else say 'Error: File already exists, "'new_file'".'
end
exit
/* --[ proc ]--------------------------- */
errorx:
parse arg text
say text
exit 5
return 0
get_ext:
parse arg get_ext_in
if lastpos('.',get_ext_in) ~= 0 then get_ext_back = substr(get_ext_in,1+lastpos('.',get_ext_in))
else get_ext_back = ''
return get_ext_back
get_base:
parse arg get_base_in
if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1)
else get_base_back = get_base_in
return get_base_back